Skip to content

Reject ignored statements and run all of them in executemultiple - #364

Merged
quinnj merged 1 commit into
masterfrom
fix/multiple-statements
Sep 30, 2026
Merged

quinnj merged 1 commit into
masterfrom
fix/multiple-statements

Conversation

@quinnj

@quinnj quinnj commented Sep 30, 2026

Copy link
Copy Markdown
Member

Closes #303.

SQL with several statements silently ran only the first one:

julia> DBInterface.execute(db, "CREATE TABLE m(a); INSERT INTO m VALUES (1)");

julia> DBInterface.execute(db, "SELECT count(*) FROM m") |> columntable
(var"count(*)" = [0],)     # the INSERT never ran, and nothing said so

julia> DBInterface.executemultiple(db, "SELECT 1 AS a; SELECT 2 AS b") |> collect
1-element ...              # only the first result

sqlite3_prepare_v2 reports where the first statement ends; we passed C_NULL for that and dropped the rest.

  • DBInterface.prepare, DBInterface.execute, and SQLite.execute now throw ArgumentError if anything but whitespace or comments follows the first statement. Python's sqlite3 does the same. Trailing ;, whitespace, and comments still work.
  • DBInterface.executemultiple(db, sql, [params]) runs every statement in order and returns their cursors. Each statement is prepared only after the previous one runs, so CREATE TABLE ...; INSERT INTO ... works. The same params go to every statement, so named parameters work across statements.

Behavior change: code that passed several statements to execute used to run only the first. It now errors, pointing to executemultiple. I think that's the right call, since the old behavior silently dropped writes, but it's worth a minor version bump.

🤖 Generated with Claude Code

prepare/execute silently ran only the first statement of SQL like
"CREATE TABLE t(a); INSERT INTO t VALUES (1)", and executemultiple
returned only the first result. Now preparing SQL with more than one
statement throws, and DBInterface.executemultiple runs each statement
in order, preparing each after the previous one runs.

Closes #303.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@quinnj quinnj mentioned this pull request Sep 30, 2026
@quinnj
quinnj merged commit 6026931 into master Sep 30, 2026
7 checks passed
@quinnj
quinnj deleted the fix/multiple-statements branch September 30, 2026 16:20
quinnj referenced this pull request Sep 30, 2026
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Query Not Running Using SQLite.jl - Runs within litecli

1 participant